﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Espam.Idiomas.Decimo.Tesis.Datos;
using System.Data;
using System.Data.SqlClient;

namespace Espam.Idiomas.Decimo.Tesis.Negocio
{
   public class Carreras
    {
       public int idCarreras { get; set; }
       public string carrera { get; set; }
    }
   public class ListadoCarreras:Carreras
   {
       public List<Carreras> GetCarreras()
       {
           BaseDatos oBase = new BaseDatos();
           SqlDataReader reader;
           List<Carreras> lista = new List<Carreras>();
           try
           {
               SqlCommand comando = new SqlCommand("sp_getCarreras",oBase.conexion);
               comando.CommandType = CommandType.StoredProcedure;
               oBase.Conectar();
               reader = comando.ExecuteReader();
               while (reader.Read())
               {
                   Carreras oCarr = new Carreras();
                   oCarr.idCarreras = reader.GetInt32(0);
                   oCarr.carrera = reader.GetString(1);
                   lista.Add(oCarr);
               }
           }
           catch (Exception)
           {
               lista = null;
           }
           finally
           {
               oBase.CerrarConexion();
           }
           return lista;
       }
   }
}
